<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * @Date: 2022-04-21 15:27:08
 * @LastEditors: Sam
 * @LastEditTime: 2022-07-13 03:53:25
 */
use think\facade\Db;
use app\admin\model\AuthRule as AuthRuleModel;

if (!AuthRuleModel::where('title', '答题管理')->count()) {

    $parent_id = AuthRuleModel::query()->create([
        'parent_id'    => 0,
        'title'        => '答题管理',
        'url'          => '#',
        'method'       => 'OPTIONS',
        'slug'         => 'question'
    ]);
     AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '题库管理',
        'url'          => 'question_index',
        'method'       => 'GET',
        'slug'         => 'question.index'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '添加题目',
        'url'          => 'question_create',
        'method'       => 'POST',
        'slug'         => 'question.create'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '编辑题目',
        'url'          => 'question_edit',
        'method'       => 'POST',
        'slug'         => 'question.edit'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '删除题目',
        'url'          => 'question_delete',
        'method'       => 'POST',
        'slug'         => 'question.delete'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '删除选项',
        'url'          => 'question_delete_OPTIONS',
        'method'       => 'POST',
        'slug'         => 'question.delete_OPTIONS'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '下载模板',
        'url'          => 'question_down_temp',
        'method'       => 'GET',
        'slug'         => 'question.down_temp'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '答题记录',
        'url'          => 'question_record',
        'method'       => 'GET',
        'slug'         => 'question.record'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '题库导入',
        'url'          => 'question_import',
        'method'       => 'POST',
        'slug'         => 'question.import'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '答题导出',
        'url'          => 'question_export',
        'method'       => 'GET',
        'slug'         => 'question.export'
    ]);
}










